package kr.pe.johnkim.sendme.util;

import kr.pe.johnkim.sendme.util.SendMeSlideMyHorizontalScrollView.SizeCallback;
import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;

/**
 * Helper that remembers the width of the 'slide' button, so that the 'slide' button remains in view, even when the menu is
 * showing.
 */
public class SendMeSlideSizeCallbackForMenu implements SizeCallback{

	/*
	 * 적당한 길이 (퍼옴)
	 * (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	private DisplayMetrics metrics;
	private static int leftMenuWidth;

	//        int btnWidth;
	//        View btnSlide;

	//        public SizeCallbackForMenu(View btnSlide) {
	public SendMeSlideSizeCallbackForMenu(Activity context) {
		super();
		//            this.btnSlide = btnSlide;
      metrics = new DisplayMetrics();
      context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
		leftMenuWidth = (int) ((metrics.widthPixels) * 0.75);
	}

	@Override
	public void onGlobalLayout() {
		//            btnWidth = btnSlide.getMeasuredWidth();
		//            System.out.println("btnWidth=" + btnWidth);
	}

	@Override
	public void getViewSize(int idx, int w, int h, int[] dims) {
		dims[0] = w;
		dims[1] = h;
		final int menuIdx = 0;
		if (idx == menuIdx) {
			//                dims[0] = w - btnWidth;
			dims[0] = leftMenuWidth;		// 보기 좋아짐..
		}
	}
}
